package top.lunarye.config;

import cn.dev33.satoken.stp.StpInterface;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import top.lunarye.modules.staff.entity.RoleEnum;
import top.lunarye.modules.staff.entity.Staff;
import top.lunarye.modules.staff.service.impl.StaffServiceImpl;

import java.util.ArrayList;
import java.util.List;

/**
 * @description: 用于为登录账号添加角色和权限
 * @author: lunar
 * @since: 2021-07-19
 */
@Component
public class StpInterfaceImpl implements StpInterface {

    @Autowired
    StaffServiceImpl staffService;

    @Override
    public List<String> getPermissionList(Object o, String s) {
        return null;
    }

    @Override
    public List<String> getRoleList(Object loginId, String s) {
        String username = (String) loginId;
        Staff staff = staffService.selectStaffByUsername(username);
        List<String> list = new ArrayList<>();
        list.add(staff.getRole().getRoleName());
        return list;
    }
}
